package com.wpx.log.core.handler;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import com.wpx.log.core.LogContext;
import com.wpx.log.core.LogRequestContext;

public class OpPathLogHandler implements ILogHandler {

	@Override
	public boolean isSync() {
		return true;
	}
	
	@Override
	public Object handler(LogContext logContext, LogRequestContext logRequestContext, Field logField) {
		HttpServletRequest request = logRequestContext.getHttpServletRequest();
		String contextPath = request.getContextPath();
		String requestURI = request.getRequestURI();
		if(requestURI == null) {
			return "";
		}
		return requestURI.substring(contextPath.length(), requestURI.length());
	}

}
